// JSDoc


/**
 * 日期格式化
 * @author webopenfather
 * @param {String} stringTime  待格式化的数据 2021-11-26 11:27:12
 * @param {String} 形参名  形参描述
 * @return String
 */
function  getTimer(stringTime)  
{
var  minute  =  1000  *  60;
var  hour  =  minute  *  60;
var  day  =  hour  *  24;
var  week  =  day  *  7;
var  month  =  day  *  30;

    var  time1  =  new  Date().getTime();//当前的时间戳
    console.log(time1);
    var  time2  =  Date.parse(new  Date(stringTime));//指定时间的时间戳
    console.log(time2);
    var  time  =  time1  -  time2;

    var  result  =  null;
    if  (time  <  0)  {
        alert("设置的时间不能早于当前时间！");
    }  else  if  (time  /  month  >=  1)  {
        result  =  "发布于"  +  parseInt(time  /  month)  +  "月前！";
    }  else  if  (time  /  week  >=  1)  {
        result  =  "发布于"  +  parseInt(time  /  week)  +  "周前！";
    }  else  if  (time  /  day  >=  1)  {
        result  =  "发布于"  +  parseInt(time  /  day)  +  "天前！";
    }  else  if  (time  /  hour  >=  1)  {
        result  =  "发布于"  +  parseInt(time  /  hour)  +  "小时前！";
    }  else  if  (time  /  minute  >=  1)  {
        result  =  "发布于"  +  parseInt(time  /  minute)  +  "分钟前！";
    }  else  {
        result  =  "刚刚发布！";
    }
    console.log(result);
    return result
}
//  getTimer("2021-11-26 11:27:12");



/**
 * 判断浏览器内核
 * @returns Object
 */
function liulanqi() 
{
    var u = navigator.userAgent;
    return {
            trident: u.indexOf('Trident') > -1, //IE内核
            presto: u.indexOf('Presto') > -1, //opera内核
            webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
            gecko: u.indexOf('Firefox') > -1, //火狐内核Gecko
            mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
            ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios
            android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android
            iPhone: u.indexOf('iPhone') > -1 , //iPhone
            iPad: u.indexOf('iPad') > -1, //iPad
            webApp: u.indexOf('Safari') > -1 //Safari
        }
    }
// console.log(liulanqi())




function isM()
{
    var browser = {
        versions: function() {
          var u = navigator.userAgent;
          return {
                  mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
                  ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios
                  android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android
                  iPhone: u.indexOf('iPhone') > -1 , //iPhone
                  iPad: u.indexOf('iPad') > -1, //iPad
                  webApp: u.indexOf('Safari') > -1 //Safari
              };
          }
      }
      if (browser.versions.mobile || browser.versions.ios || browser.versions.android || browser.versions.iPhone || browser.versions.iPad) {
        //   alert('移动端');
        return true
      }else{
        //   alert('PC')
        return false 
    }
}

